import 'package:flutter/material.dart';

import '../pages/tabs.dart';
import '../pages/textfield.dart';
import '../pages/checkbox.dart';
import '../pages/radio.dart';
import '../pages/form.dart';
import '../pages/datepicker.dart';
import '../pages/datepicker-pub.dart';

//配置路由
final routes={
    '/': (context)=> Tabs(),
    '/textFeildPage': (context) => TextFieldPage(),
    '/checkBoxPage': (context) => CheckBoxPage(),
    '/radioPage': (context) => RadioPage(),
    '/formPage': (context) => FormPage(),
    '/datePicker': (context) => DatePickerDemo(),
    '/datePickerPub': (context) => DatePickerPubDemo(),
};

//固定写法
var onGenerateRoute = (RouteSettings settings) {
      // 统一处理
      final String name = settings.name; 
      final Function pageContentBuilder = routes[name];
      if (pageContentBuilder != null) {
        if (settings.arguments != null) {
          final Route route = MaterialPageRoute(
              builder: (context) =>
                  pageContentBuilder(context, arguments: settings.arguments));
          return route;
        }else{
            final Route route = MaterialPageRoute(
              builder: (context) =>
                  pageContentBuilder(context));
            return route;
        }
      }
};